package com.huilian.iotbox.admin.wap.controller;

import com.huilian.iotbox.admin.wap.service.MoneyWithdrawService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.MoneyWithdrawDto;
import com.huilian.iotbox.data.po.MoneyWithdraw;
import com.huilian.iotbox.data.vo.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 谢洛涛
 * @date 2021/4/23 12:23
 */
@RestController
@Slf4j
@RequestMapping("/api/moneyWithdraw")
public class MoneyWithdrawController extends UserInfoController {
    @Autowired
    private MoneyWithdrawService moneyWithdrawService;
    /**申请提现**/
    @PostMapping
    public ServerResponse AddMoneyWithdraw(HttpServletRequest request, @RequestBody MoneyWithdrawDto moneyWithdrawDto) throws Exception{
        UserInfo userInfo = super.getLoginUserInfo(request);
        moneyWithdrawDto.setUserInfo(userInfo);
        return moneyWithdrawService.AddMoneyWithdraw(moneyWithdrawDto);
    }
    @GetMapping("/list")
    public ServerResponse findMoneyWithdrawList(HttpServletRequest request, MoneyWithdraw moneyWithdraw){
        UserInfo userInfo = super.getLoginUserInfo(request);
        moneyWithdraw.setUserInfo(userInfo);
        return ServerResponse.createBySuccess(moneyWithdrawService.findMoneyWithdrawList(moneyWithdraw));
    }
}
